<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>H+ 后台主题UI框架 - jqGird</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">

    <title>Title</title>
    <link rel="shortcut icon" href="favicon.ico">
    <link href="${(basicContextPath)!}/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="${(basicContextPath)!}/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="${(basicContextPath)!}/css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet">
    <link href="${(basicContextPath)!}/css/plugins/bootstraps-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="${(basicContextPath)!}/css/animate.css" rel="stylesheet">
    <link href="${(basicContextPath)!}/css/style.css?v=4.1.0" rel="stylesheet">
    <link rel="stylesheet" href="${(basicContextPath)!}/css/plugins/sweetalert/sweetalert.css">


</head>

<body class="gray-bg">
<div class="wrapper wrapper-content  animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>文本审核</h5>
                </div>
                <div class="ibox-content">
                    <form role="form" class="form-inline">
                        <div class="form-group">
                            <label class="sr-only">审核类型</label>
                            <select class="form-control" name="contentSourceType" id="contentSourceType">
                                <option value="">昵称</option>
                                <option value="3">昵称</option>
                                <option value="4">昵称</option>
                                <option value="5">昵称</option>
                            </select>
                        </div>
                        <div class="form-group">
                            <label class="">发送人</label>
                            <input type="text" placeholder="请输入发送人" id="sender" name="sender" class="form-control">
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">发送日期：</label>
                            <div class="col-sm-10">
                                <input placeholder="开始时间" class="form-control layer-date laydate-icon" id="sendStartTime" name="sendStartTime">
                                <input placeholder="结束时间" class="form-control layer-date laydate-icon" id="sendEndTime" name="sendEndTime">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="">审核内容</label>
                            <input type="text" placeholder="请输入审核内容" name="censorContent" id="censorContent"
                                   class="form-control">
                        </div>
                        <div class="form-group">
                            <button class="btn btn-white" type="button" onclick="queryDispatchOrder()">搜索</button>
                        </div>
                    </form>
                    <div class="hr-line-dashed"></div>
                    <div class="form-group">

                        <div class="btn-group">
                            <button class="btn btn-white" type="button" value="11">全部</button>
                            <button class="btn btn-primary" type="button">已人工审核</button>
                            <button class="btn btn-white" type="button">未人工审核</button>
                        </div>

                    </div>
                    <div class="hr-line-dashed"></div>
                    <div class="form-group">

                        <div class="btn-group">
                            <a class="btn btn-default btn-rounded" href="buttons.html#" >全部等级</a>
                            <a class="btn btn-primary btn-rounded" href="buttons.html#">1级</a>
                            <a class="btn btn-success btn-rounded" href="buttons.html#">2级</a>
                            <a class="btn btn-info btn-rounded" href="buttons.html#">3级</a>
                            <a class="btn btn-warning btn-rounded" href="buttons.html#">4级</a>
                        </div>

                    </div>

                </form>
            </div>
        </div>

    </div>
    <div class="row">
        <div class="ibox-title">

        </div>
        <div class="ibox-content">
            <div>
                <table class="table table-striped table-bordered" id="orderItemTable" width="100%">
                    <thead>
                    <tr style="text-align-last: center">
                        <th><input class="checkAll" type="checkbox" value="" id="checkAll" onclick="selectAll()">全选</th>
                        <th>审核等级</th>
                        <th>内容</th>
                        <th>发送人</th>
                        <th>电话</th>
                        <th>发送时间</th>
                        <th>审核</th>
                    </tr>
                    </thead>
                    <tbody>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>

</div>


<!-- Page-Level Scripts -->
<!-- 全局js -->
<script src="${(basicContextPath)!}/js/jquery.min.js?v=2.1.4"></script>
<script src="${(basicContextPath)!}/js/bootstrap.min.js?v=3.3.6"></script>

<!-- dataTable -->
<script src="${(basicContextPath)!}/js/plugins/dataTables/jquery.dataTables.js"></script>

<!-- Peity -->
<script src="${(basicContextPath)!}/js/plugins/dataTables/dataTables.bootstrap.js"></script>

<!-- 自定义js -->
<script src="${(basicContextPath)!}/js/content.js?v=1.0.0"></script>
<script src="${(basicContextPath)!}/js/plugins/layer/laydate/laydate.js"></script>
<script>
    //日期范围限制
    /*var start = {
        elem: '#start',
        format: 'YYYY/MM/DD hh:mm:ss',
        min: laydate.now(), //设定最小日期为当前日期
        max: '2099-06-16 23:59:59', //最大日期
        istime: true,
        istoday: false,
        choose: function (datas) {
            end.min = datas; //开始日选好后，重置结束日的最小日期
            end.start = datas //将结束日的初始值设定为开始日
        }
    };
        var end = {
        elem: '#end',
        format: 'YYYY/MM/DD hh:mm:ss',
        min: laydate.now(),
        max: '2099-06-16 23:59:59',
        istime: true,
        istoday: false,
        choose: function (datas) {
            start.max = datas; //结束日选好后，重置开始日的最大日期
        }
    };
    laydate(start);
    laydate(end);*/
    function queryDispatchOrder1() {

    }
    function queryDispatchOrder() {

        $("#orderItemTable").dataTable({
            "filter": false,//去掉搜索框
            "ordering": false, // 是否允许排序
            "destroy": true,
            "serverSide": true, //开启服务器处理模式
            "processing": true,
            "paging": true,
            "bLengthChange": false,
            "bInfo": true,
            "bAutoWidth": false,
            "bPaginage": true,
            "lengthChange": false,
            "scrollX": true, // 是否允许左右滑动
            "displayLength": 10, // 默认长度
            "deferRender": true,
            "defaultContent": "",
            //当处理大数据时，延迟渲染数据，有效提高Datatables处理能力
            "ajax": { // 请求地址
               // url: "/qy/bill/list",
                url: "/content/getAllCensorContent",
                type: "post",
                dataType: "json",
                contentType: "application/json",
                data: function (d) {
                    var param = {};
                    //   param.startIndex = data.start+1;//开始的记录序号
                    param.pageSize = d.length;//页面显示记录条数，在页面显示每页显示多少项的时候
                    param.pageNum = (d.start / d.length + 1);//当前页码
                    param.contentSourceType = $("#contentSourceType").val();
                    //console.log(param.corporateName)
                    param.sender = $("#sender").val();
                    param.censorContent = $("#censorContent").val();
                    param.sender = $("#sendStartTime").val();
                    param.censorContent = $("#sendEndTime").val();
                    console.log(JSON.stringify(param));
                    return JSON.stringify(param);
                },
                "dataFilter": function (json) {//json是服务器端返回的数据
                    console.log("查询中。。。。。。。。。。")
                    console.log(json.data);
                    //alert("json+"+json);
                    json = JSON.parse(json);
                    var returnData = {};
                    //     returnData.draw = json.draw;
                    returnData.recordsTotal = json.total;//返回数据全部记录
                    //alert("recordsTotal"+returnData.recordsTotal)
                    console.log("查询中。。。。。。。。。。")
                        returnData.recordsFiltered = json.total;//后台不实现过滤功能，每次查询均视作全部结果
                    if (json.total == 0) {
                        returnData.data = {}
                    } else {
                        returnData.data = json.list;//返回的数据列表、、
                    }
                    return JSON.stringify(returnData);//这几个参数都是datatable需要的，必须要
                }
            },
            "columns": [ // 数据映射
                {"data": ''},
                {"data": "censorLevel"},
                {"data": "censorContent"},
                {"data": "sender"},
                {"data": "senderPhone"},
                {"data": "sendTime"},
                {"data": ''}
            ],
            "oLanguage": { // 国际化配置
                "sProcessing": "正在处理，请稍后",
                "sLengthMenu": "显示 _MENU_ 条",
                "sZeroRecords": "没有找到数据",
                "sInfo": "从 _START_ 到  _END_ 条记录 总记录数为 _TOTAL_ 条",
                "sInfoFiltered": "(全部记录数 _MAX_ 条)",
                "sInfoPostFix": "",
                "sSearch": "查询",
                "sUrl": "",
                "oPaginate": {
                    "sFirst": "第一页",
                    "sPrevious": "上一页",
                    "sNext": "下一页",
                    "sLast": "最后一页"
                }
            },
            "columnDefs": [{
                "targets": 0,
                "data": "id",
                "render": function (data, type, row, meta) {
                    console.log(row.id)
                    //  console.log(row);
                    return '<input type="checkbox" name="chk_list" onclick="childClick(' + row.id + ')" value="' + row.id + '" />';
                }
            }]/*,
            "fnDrawCallback": function () {
                $(this).find('thead input[type=checkbox]').removeAttr('checked');
            }*/
        });
    }
    /*var chk_value = [];//定义一个数组*/
    $(document).ready(function () {
        queryDispatchOrder();
    });

    function childClick(id) {
        console.log(id);
        if ($(this).is(":checked") == false) {
            $("#checkAll").prop("checked", false);
        }
    }

    function audit() {
        $('input[type="checkbox"][name="chk_list"]:checked').each(function (e) {

            singleSelect.push($(this).val());
            console.log($(this).val())
        });
        console.log(singleSelect.length);
        if (singleSelect.length == 0) {
            swal({
                title: "请选择操作项",
                text: "请选择",
                type: "error"
            });
            return false;
        }
        var test = $('th:last').text();

        console.log(JSON.stringify(singleSelect));
        $.ajax({
            type: "post",
            url: '/qy/bill/audit',
            data: JSON.stringify(singleSelect),
            contentType: 'application/json;charset=UTF-8', //contentType很重要
            success: function (data) {


                console.log(data.message)
                if (data.data == 0) {
                    swal({
                        title: "审批失败",
                        text: data.message,
                        type: "error"
                    });
                }
                if (data.data != 0) {
                    swal({
                        title: "审批成功",
                        text: "审批成功",
                        type: "success"
                    });
                    //queryDispatchOrder();
                    $("#checkAll").prop("checked", false);
                    singleSelect = [];
                    // $('#enterpriseModal').modal('hide');
                } else {
                    singleSelect = [];
                    $("#checkAll").prop("checked", false);
                }
                queryDispatchOrder();
            }
        });
    }

    function pay() {
        $('input[type="checkbox"][name="chk_list"]:checked').each(function (e) {
            // alert($(this).val());
            singleSelect.push($(this).val());
            console.log(singleSelect)
        });
        console.log(singleSelect.length);
        if (singleSelect.length == 0) {
            swal({
                title: "请选择操作项",
                text: "请选择",
                type: "error"
            });
            return false;
        }
        /*var status = $('#status').val();
        if($('#status').val() != '1'){
            swal({
                title: "该账单付款",
                text: "请选择已审核的账单",
                type: "error"
            });
            return false;
        }*/
        console.log(JSON.stringify(singleSelect));
        $.ajax({
            type: "post",
            url: '/qy/bill/pay',
            data: JSON.stringify(singleSelect),
            contentType: 'application/json;charset=UTF-8', //contentType很重要
            success: function (data) {
                //   alert(data.data)
                console.log(data)
                console.log(data.data)
                if (data.data==false){
                    swal({
                        title: "付款失败",
                        text: data.message,
                        type: "error"
                    });
                    queryDispatchOrder();
                    $("#checkAll").prop("checked", false);
                    singleSelect = [];
                }
                if (data.data==true) {
                    swal({
                        title: "付款成功",
                        text: "付款成功",
                        type: "success"
                    });
                    queryDispatchOrder();
                    singleSelect = [];
                    // $('#enterpriseModal').modal('hide');
                } else {
                    singleSelect = [];
                    $("#checkAll").prop("checked", false);
                }
                queryDispatchOrder();
            }
        });
    }

    function selectAll() {
        var chk_value = [];//定义一个数组
        $("input[type='checkbox']").each(function (e) {
            if ($(this).prop("checked") == true) {
                console.log(e)
                $("input[name='chk_list']").prop('checked', true);
                if ($(this).val() != '' || $(this).val() != null) {
                    chk_value.push($(this).val());
                    console.log(chk_value);
                }
                return;
            } else {
                $("input[type='checkbox']").prop('checked', false);
                console.log(chk_value)
                chk_value = null;
                console.log(chk_value);
                return;
            }
        });
    }

    var singleSelect = [];

    function childclick(ths) {
        /*if ($(this).is(":checked") == false) {
            console.log(ths)
          //  console.log($(this).val());

            $("#checkAll").prop("checked", false);

        }*/
        console.log("ssss")
    }

    </script>

</body>

</html>